package com.prs.crm.dao.oa.impl;

import java.sql.SQLException;
import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.oa.JobPlanDetailDao;
import com.prs.crm.domain.oa.JobPlan;
import com.prs.crm.domain.oa.JobPlanDetail;

public class JobPlanDetailDaoImpl extends BaseDaoImpl<JobPlanDetail> implements JobPlanDetailDao{

	@Override
	@SuppressWarnings("unchecked")
	public Collection<JobPlanDetail> getJobPlanDetailByJobPlan(final JobPlan jobPlan) {
		// TODO Auto-generated method stub
		return (Collection<JobPlanDetail>) this.getHibernateTemplate().execute(new HibernateCallback() {

			@Override
			public Object doInHibernate(Session arg0)
					throws HibernateException, SQLException {
				// TODO Auto-generated method stub
				Criteria criteria = arg0.createCriteria(JobPlanDetail.class);
				criteria.add(Restrictions.eq("jobPlan", jobPlan));
				return criteria.list();
			}
			
		});
	}

}
